<?php
// 初始化变量及引入初始文件
$dbPathPart		= '';
$webPathPart	= '';
$jsPathPart		= '';

require(dirname(__FILE__) .'/check.php');

$userSysArr = Cache::PhpFile('userSys');

if ($userSysArr['US_isUserSys'] == 0){
	die('<br /><br /><center>会员系统已关闭，有问题请联系管理员</center>');
}

	$username = Users::Username();

	if ($username == ''){
		$backURL = urlencode(GetUrl::Query());
		die('
		<br /><br />
		<center style="font-size:14px;">
			请先登录，该功能需要登录才能使用。
			如有账号请先 <a style="color:red;" href="users.php?mudi=login&force=1&backURL='. $backURL .'">[登录]</a>，如没账号请先 <a style="color:red;" href="users.php?mudi=reg&force=1&backURL='. $backURL .'">[注册]</a>
		</center>
		<br /><br />
		');
	}

	$addiFieldStr = '';
	switch ($mudi){
		case 'recom':	$addiFieldStr = ',UE_recomLevel,UE_recomUser,UE_recomNum1,UE_recomNum2,UE_recomNum11,UE_recomNum12';	break;
	}
	$userRow = Users::Open('get',',UE_username,UE_authStr,UE_groupID,UE_isAgent,UE_state,UE_cardState,UE_pageNum'. $addiFieldStr,'',$judUserErr);
		if ((! $userRow) || $judUserErr != ''){
			$backURL = urlencode(GetUrl::Query());
			die('
			<br /><br />
			<center style="font-size:14px;">
				请先登录，该功能需要登录才能使用（'. $judUserErr .'）。 如有账号请先 <a style="color:red;" href="users.php?mudi=login&force=1&backURL='. $backURL .'">[登录]</a>，如没账号请先 <a style="color:red;" href="users.php?mudi=reg&force=1&backURL='. $backURL .'">[注册]</a>
			</center>
			<br /><br />
			');
		}

		if (! in_array($mudi, array('revInfo', 'siteMessage', 'siteMessageAdd', 'siteMessageReply', 'userAndGroup', 'gift', 'workUsers', 'payRecord', 'diyPayRecord', 'moneyRecord', 'userScore','workOrderAdd','workOrderReply','workOrderManage','domainTpl','domainTplRev','domainTplAdd'))){	// ,'domainManage','domainXufei','domainOut'
			// 检测用户邮箱、手机号是否需要强制验证
			AreaApp::UserTixing($userRow['UE_authStr'], $userSysArr, 1);
		}
		if ($userRow['UE_pageNum'] < 1){ $userRow['UE_pageNum'] = 20; }

require(OT_ROOT .'inc/classTemplate.php');

$tpl = new Template;

// 初始化公共变量
$tpl->webTypeName	= 'usersCenter';
$tpl->webTitle		= '';
$tpl->webKey		= '*';
$tpl->webDesc		= '*';

if (empty($userSysArr['US_userAndGroupName'])){ $userSysArr['US_userAndGroupName'] = '会员和会员组'; }

$webContImg = '';
$webContent = StrInfo::AlertStr('ucAudit0');
switch ($mudi){
	case 'revInfo':
		$webTitle	= '资料密码修改';
		if (Area::UcAudit('|noRightRevInfo|')){
			$webContent = UsersCenter::RevInfo($userRow['UE_ID']);
		}
		$webContImg = 'address-card-o';
		break;

	case 'userAndGroup':
		$webTitle	= $userSysArr['US_userAndGroupName'];
		$webContent = UsersCenter::UserAndGroup($userRow['UE_ID']);
		$webContImg = 'address-card-o';
		break;

	case 'userGroupRightList':
		$webTitle	= '会员组权限列表';
		$webContent = UserGroup::RightList($userRow['UE_ID']);
		$webContImg = 'address-card-o';
		break;

	case 'log':
		$webTitle	= '会员日志';
		if (Area::UcAudit('|noRightLog|')){
			$webContent = UsersCenter::LogWeb($userRow['UE_ID']);
		}
		break;

	case 'addNews':
		$webTitle	= '发表文章';
		if (Area::UcAudit()){
			$webContent = UsersNews::AddOrRev();
		}
		$webContImg = 'newspaper-o';
		break;

	case 'revNews':
		$webTitle	= '修改文章';
		if (Area::UcAudit()){
			$webContent = UsersNews::AddOrRev();
		}
		$webContImg = 'newspaper-o';
		break;

	case 'newsManage':
		$webTitle	= '文章管理';
		$webContent = UsersNews::Manage();
		break;

	case 'loginApi':
		$webTitle	= '快捷登录绑定';
		$webContent = AppLogin::UcManage($userRow['UE_ID']);
		break;

	case 'quan':
		$webTitle	= '卡密充值';
		if (Area::UcAudit('|noRightQuan|')){
			$webContent = AppQuan::UcPayWeb($userRow['UE_ID']);
		}
		break;

	case 'onlinePay':
		$webTitle	= '在线充值';
		if (Area::UcAudit('|noRightPay|')){
			$webContent = AppMoneyPay::UcPayWeb($userRow['UE_ID'],$userRow['UE_username']);
		}
		break;

	case 'payRecord':
		$webTitle	= '充值记录';
		$webContent = AppMoneyPay::UcManage($userRow['UE_ID']);
		break;

	case 'diyPayRecord':
		$webTitle	= '手动充值记录';
		$webContent = AppDiyPay::UcManage($userRow['UE_ID']);
		break;

	case 'moneyRecord':
		$webTitle	= '财务明细';
		$webContent = AppMoneyRecord::UcManage($userRow['UE_ID']);
		break;

	case 'userScore':
		$webTitle	= '积分明细';
		$webContent = AppUserScore::UcManage($userRow['UE_ID']);
		break;

	case 'gift':
		$webTitle	= '积分兑换记录';
		$webContent = AppGift::UcManage($userRow['UE_ID']);
		break;

	case 'recom':
		$webTitle	= '邀请好友';
		if (Area::UcAudit()){
			$webContent = AppRecom::UcManage($userRow['UE_ID']);
		}
		break;

	case 'buyOrders':
		$webTitle	= '订单记录';
		if (Area::UcAudit()){
			$webContent = AppBuyOrders::UcManage($userRow['UE_ID']);
		}
		break;

	case 'goodsOrder':
		$webTitle	= '淘宝商品认领';
		$webContent = AppTaokeOrder::UcManage($userRow['UE_ID']);
		break;

	case 'workCenter':
		$webTitle	= '任务中心';
		if (Area::UcAudit('|noRightWorkCenter|')){
			$webContent = AppWorkCenter::UcManage($userRow['UE_ID']);
		}
		break;

	case 'workUsers':
		$webTitle	= '任务记录';
		$webContent = AppWorkCenter::UcUsers($userRow['UE_ID']);
		break;

	case 'gainMoney':
		$webTitle	= '提现记录';
		if (Area::UcAudit()){
			$webContent = AppGain::UcMoneyManage($userRow['UE_ID']);
		}
		break;

	case 'gainItem':
		$webTitle	= '佣金记录';
		$webContent = AppGain::UcItemManage($userRow['UE_ID']);
		break;

	case 'userView':
		$webTitle	= '文章浏览记录';
		$webContent = AppUserView::UcManage($userRow['UE_ID']);
		break;

	case 'userMark':
		$webTitle	= '文章收藏记录';
		$webContent = AppUserMark::UcManage($userRow['UE_ID']);
		break;

	case 'infoDown':
		$webTitle	= '文章下载记录';
		$webContent = AppInfoDown::UcManage($userRow['UE_ID']);
		break;

	case 'siteMessage':
		$webTitle	= '站内信息';
		$webContent = AppSiteMessage::UcManage($userRow['UE_ID']);
		break;

	case 'siteMessageAdd':
		$webTitle	= '提交站内信息';
		$webContent = AppSiteMessage::UcAdd($userRow['UE_ID']);
		break;

	case 'siteMessageReply':
		$webTitle	= '回复站内信息';
		$webContent = AppSiteMessage::UcReply($userRow['UE_ID']);
		break;

	case 'api':
		$webTitle	= 'API授权码';
		if (Area::UcAudit('|noRightApi|')){
			$webContent = AppSiteApi::Manage($userRow['UE_ID']);
		}
		break;

	case 'ca':
		$webTitle	= '广告管理';
		$webContent = AppCa::UcManage($userRow['UE_ID']);
		break;

	case 'form':
		$webTitle	= '表单管理';
		$webContent = AppForm::UcManage($userRow['UE_ID']);
		break;

	case 'formDet':
		$webTitle	= '表单详情列表';
		$webContent = AppForm::UcManageDet($userRow['UE_ID']);
		break;

	case 'onePage':
		$webTitle	= '功能单页';
		$webContent = AppOnePage::UcManage($userRow['UE_ID']);
		break;

	case 'onePageRev':
		$webTitle	= '修改功能单页';
		$webContent = AppOnePage::UcRev($userRow['UE_ID']);
		break;

	case 'audioVideo':
		$webTitle	= '音乐视频库';
		$webContent = AppAudioVideo::UcManage($userRow['UE_ID']);
		break;

	case 'audioVideoDeal':
		$webTitle	= '音乐视频添加/修改';
		$webContent = AppAudioVideo::UcRev($userRow['UE_ID']);
		break;

	case 'getGift':
		$webTitle	= '抽奖记录';
		$webContent = AppGetGift::UcManage($userRow['UE_ID']);
		break;

	case 'workOrderAdd':
		$webTitle	= '提交工单';
		$webContent = AppWorkOrder::Add();
		$webContImg = 'newspaper-o';
		break;

	case 'workOrderReply':
		$webTitle	= '工单回复';
		$webContent = AppWorkOrder::Reply();
		$webContImg = 'newspaper-o';
		break;

	case 'workOrderManage':
		$webTitle	= '工单管理';
		$webContent = AppWorkOrder::Manage();
		break;


	case 'domainTpl':
		$webTitle	= '域名注册模板';
		$webContent = AppDomainTpl::Manage($userRow['UE_ID']);
		break;

	case 'domainTplRev':
		$webTitle	= '修改域名注册模板';
		$webContent = AppDomainTpl::AddOrRev($userRow['UE_ID']);
		break;

	case 'domainTplAdd':
		$webTitle	= '新增域名注册模板';
		$webContent = AppDomainTpl::AddOrRev($userRow['UE_ID']);
		break;

	case 'domainManage':
		$webTitle	= '域名管理';
		$webContent = AppDomainUc::Manage($userRow['UE_ID']);
		break;

	case 'domainXufei':
		$webTitle	= '域名续费';
		$webContent = AppDomainUc::Xufei($userRow['UE_ID']);
		break;

	case 'domainOut':
		$webTitle	= '域名转出';
		$webContent = AppDomainUc::Zhuanchu($userRow['UE_ID']);
		break;


	case 'hostKaitong':
		$webTitle	= '虚拟主机开通';
		$webContent = AppHostUc::Kaitong();
		break;

	case 'hostKaitongDet':
		$webTitle	= '虚拟主机开通 - 详细信息';
		if (Area::UcAudit()){
			$webContent = AppHostUc::KaitongDet($userRow['UE_ID']);
		}
		break;

	case 'hostManage':
		$webTitle	= '虚拟主机管理';
		$webContent = AppHostUc::Manage($userRow['UE_ID']);
		break;

	case 'hostManage_xufei':
		$webTitle	= '虚拟主机管理 - 续费';
		if (Area::UcAudit()){
			$webContent = AppHostUc::Xufei($userRow['UE_ID']);
		}
		break;

	case 'hostManage_update':
		$webTitle	= '虚拟主机管理 - 升级';
		if (Area::UcAudit()){
			$webContent = AppHostUc::Update($userRow['UE_ID']);
		}
		break;

	case 'hostManage_zhuanzheng':
		$webTitle	= '虚拟主机管理 - 转正';
		if (Area::UcAudit()){
			$webContent = AppHostUc::Zhuanzheng($userRow['UE_ID']);
		}
		break;

	case 'hostManage_tuikuan':
		$webTitle	= '虚拟主机管理 - 退款';
		if (Area::UcAudit()){
			$webContent = AppHostUc::Tuikuan($userRow['UE_ID']);
		}
		break;


	case 'vpsKaitong':
		$webTitle	= '云服务器开通';
		$webContent = AppVpsApiUc::Kaitong();
		break;

	case 'vpsKaitongDet':
		$webTitle	= '云服务器开通 - 详细信息';
		if (Area::UcAudit()){
			$webContent = AppVpsApiUc::KaitongDet($userRow['UE_ID']);
		}
		break;

	case 'vpsManage':
		$webTitle	= '云服务器管理';
		$webContent = AppVpsApiUc::Manage($userRow['UE_ID']);
		break;

	case 'vpsManage_xufei':
		$webTitle	= '云服务器管理 - 续费';
		if (Area::UcAudit()){
			$webContent = AppVpsApiUc::Xufei($userRow['UE_ID']);
		}
		break;

	case 'vpsManage_update':
		$webTitle	= '云服务器管理 - 升级';
		if (Area::UcAudit()){
			$webContent = AppVpsApiUc::Update($userRow['UE_ID']);
		}
		break;

	case 'vpsManage_zhuanzheng':
		$webTitle	= '云服务器管理 - 转正';
		if (Area::UcAudit()){
			$webContent = AppVpsApiUc::Zhuanzheng($userRow['UE_ID']);
		}
		break;

	case 'vpsManage_tuikuan':
		$webTitle	= '云服务器管理 - 退款';
		if (Area::UcAudit()){
			$webContent = AppVpsApiUc::Tuikuan($userRow['UE_ID']);
		}
		break;


	case 'dialingKaitong':
		$webTitle	= '拨号VPS开通';
		$webContent = AppDialingUc::Kaitong();
		break;

	case 'dialingKaitongDet':
		$webTitle	= '拨号VPS开通 - 详细信息';
		if (Area::UcAudit()){
			$webContent = AppDialingUc::KaitongDet($userRow['UE_ID']);
		}
		break;

	case 'dialingManage':
		$webTitle	= '拨号VPS管理';
		$webContent = AppDialingUc::Manage($userRow['UE_ID']);
		break;

	case 'dialingManage_xufei':
		$webTitle	= '拨号VPS管理 - 续费';
		if (Area::UcAudit()){
			$webContent = AppDialingUc::Xufei($userRow['UE_ID']);
		}
		break;

	case 'dialingManage_update':
		$webTitle	= '拨号VPS管理 - 升级';
		if (Area::UcAudit()){
			$webContent = AppDialingUc::Update($userRow['UE_ID']);
		}
		break;

	case 'dialingManage_zhuanzheng':
		$webTitle	= '拨号VPS管理 - 转正';
		if (Area::UcAudit()){
			$webContent = AppDialingUc::Zhuanzheng($userRow['UE_ID']);
		}
		break;

	case 'dialingManage_tuikuan':
		$webTitle	= '拨号VPS管理 - 退款';
		if (Area::UcAudit()){
			$webContent = AppDialingUc::Tuikuan($userRow['UE_ID']);
		}
		break;


	case 'pptpKaitong':
		$webTitle	= 'PPTP开通';
		$webContent = AppPptp::Kaitong();
		break;

	case 'pptpKaitongDet':
		$webTitle	= 'PPTP开通 - 详细信息';
		if (Area::UcAudit()){
			$webContent = AppPptp::KaitongDet($userRow['UE_ID']);
		}
		break;

	case 'pptpManage':
		$webTitle	= 'PPTP管理';
		$webContent = AppPptp::Manage($userRow['UE_ID']);
		break;

	case 'pptpManage_xufei':
		$webTitle	= 'PPTP管理 - 续费';
		if (Area::UcAudit()){
			$webContent = AppPptp::Xufei($userRow['UE_ID']);
		}
		break;

	case 'pptpManage_tuikuan':
		$webTitle	= 'PPTP管理 - 退款';
		if (Area::UcAudit()){
			$webContent = AppPptp::Tuikuan($userRow['UE_ID']);
		}
		break;


	case 'servManage':
		$webTitle	= '服务器租用管理';
		$webContent = AppServ::Manage($userRow['UE_ID']);
		break;

	case 'servManage_xufei':
		$webTitle	= '服务器租用管理 - 续费';
		$webContent = AppServ::Xufei($userRow['UE_ID']);
		break;


	case 'sslManage':
		$webTitle	= 'SSL证书管理';
		$webContent = AppSsl::Manage($userRow['UE_ID']);
		break;

	case 'sslManage_xufei':
		$webTitle	= 'SSL证书管理 - 续费';
		$webContent = AppSsl::Xufei($userRow['UE_ID']);
		break;


	case 'agentUsers':
		$webTitle	= '代理子用户管理';
		$webContent = AppAgent::UcManage($userRow['UE_ID']);
		break;

	case 'agentUsersAdd':
		$webTitle	= '添加代理子用户';
		if (Area::UcAudit()){
			$webContent = AppAgent::AddOrRev($userRow['UE_ID']);
		}
		$webContImg = 'newspaper-o';
		break;

	case 'agentUsersRev':
		$webTitle	= '修改代理子用户';
		if (Area::UcAudit()){
			$webContent = AppAgent::AddOrRev($userRow['UE_ID']);
		}
		break;

	case 'agentUsersManage':
		$webTitle	= '代理子用户产品列表';
		$webContent = AppAgent::UserManage($userRow['UE_ID']);
		break;

	case 'agentUsersPro':
		$webTitle	= '代理子用户产品归属';
		if (Area::UcAudit()){
			$webContent = AppAgent::ProManage($userRow['UE_ID']);
		}
		break;

	case 'index':
	default :
		$mudi = '';
		$webTitle	= '会员中心';
		$webContent = UsersCenter::index($userRow['UE_ID']);
		break;

}
if (strlen($mudi) > 0){
	if (strlen($webContImg) == 0){ $webContImg = 'snowflake-o'; }
	$webContent = MainArea($webContent, $webTitle, $webContImg);
}

$tpl->areaName		= $webTitle;
$tpl->webTitle		= str_replace(array('{%标题附加%}','{%标题%}'), array('',$webTitle), $tplSysArr['TS_titleWeb']);


// 解析页面
$tpl->WebTop();
$tpl->WebBottom();


$webTop = '
	<ul>
	<li style="border:none;">欢迎您，'. $userRow['UE_username'] .'</li>
	<li><a href="usersCenter.php">会员中心首页</a></li>
	'. AppWorkOrder::UcTopMenu() .'
	'. AppMoneyPay::UcTopMenu() .'
	<li><a href="usersCenter.php?mudi=revInfo">资料密码修改</a></li>
	<li><a href="./">网站首页</a></li>
	<li><a href="#" onclick="UserExit();return false;">退出</a></li>
	</ul>
	';


// 功能模块
$funcMenuStr = ''.
	AppForm::UcMenu() .
	AppBuyOrders::UcMenu() .
	AppCa::UcMenu() .
	AppTaokeOrder::UcMenu() .
	AppWorkCenter::UcMenu() .
	AppGift::UcMenu() .
	AppGetGift::UcMenu() .
	AppOnePage::UcMenu() .
	'';
if (strlen($funcMenuStr) > 5){
	$funcMenuStr = '
		<li>
			<div class="item"><i class="fa fa-puzzle-piece fa-fw"></i> 功能模块<i class="arrow"></i></div>
			<ul class="sub">'. $funcMenuStr .'</ul>
		</li>
		';
}

// 推广返佣
$recomMenuStr = ''.
	AppRecom::UcMenu() .
	AppGain::UcMenu() .
	'';
if (strlen($recomMenuStr) > 5){
	$recomMenuStr = '
		<li>
			<div class="item"><i class="fa fa-share-alt fa-fw"></i> 推广返佣<i class="arrow"></i></div>
			<ul class="sub">'. $recomMenuStr .'</ul>
		</li>
		';
}

// 财务菜单
$moneyMenuStr = ''.
	AppQuan::UcMenu() .
	AppMoneyPay::UcMenu() .
	AppDiyPay::UcMenu() .
	AppMoneyRecord::UcMenu() .
	AppUserScore::UcMenu() .
	'';
if (strlen($moneyMenuStr) > 5){
	$moneyMenuStr = '
		<li>
			<div class="item"><i class="fa fa-dollar fa-fw"></i> 财务相关<i class="arrow"></i></div>
			<ul class="sub">'. $moneyMenuStr .'</ul>
		</li>
		';
}

$cardStateStr = '<span style="color:red;font-weight:bold;">进入实名认证</span>';
switch ($userRow['UE_cardState']){
	case 1:		$cardStateStr = '<span style="color:blue;">已实名认证</span>';	break;
	case 11:	$cardStateStr = '<span style="color:blue;">已微信实名</span>';	break;
	case 21:	$cardStateStr = '<span style="color:blue;">已支付宝实名</span>';	break;
}

$webMenu = '
	<script language="javascript" type="text/javascript" src="js/usersCenter.js?v='. OT_VERSION .'"></script>

	<ul class="menu">
	<li>
		<div class="item"><i class="fa fa-paperclip fa-fw"></i> 菜单导航<i class="arrow"></i></div>
		<ul class="sub">
		'. ($userSysArr['US_isShiming'] > 0 ? '<li><a href="usersCenter.php?mudi=revInfo&revType=shiming">'. $cardStateStr .'</a></li>' : '') .'
		<li><a href="usersCenter.php">会员中心首页</a></li>
		<li><a href="usersCenter.php?mudi=userAndGroup">'. $userSysArr['US_userAndGroupName'] .'</a></li>
		'. AppSiteMessage::UcMenu() .'
		'. AppAgent::UcMenu($userRow['UE_isAgent']) .'
		'. UsersNews::UcMenu() .'
		'. AppUserView::UcMenu() .'
		'. AppUserMark::UcMenu() .'
		'. AppInfoDown::UcMenu() .'
		</ul>
	</li>
	<li>
		<div class="item"><i class="fa fa-cubes fa-fw"></i> 产品管理<i class="arrow"></i></div>
		<ul class="sub">
		'. AppDomainUc::MenuBox() .'
		'. AppHostUc::MenuBox() .'
		<li><a href="usersCenter.php?mudi=vpsManage">云服务器</a></li>
		'. AppDialingUc::MenuBox() .'
		'. AppServ::UcMenu() .'
		'. AppSsl::UcMenu() .'
		</ul>
	</li>
	'. $funcMenuStr .'
	'. $recomMenuStr .'
	'. $moneyMenuStr .'
	'. AppWorkOrder::UcMenu() .'
	<li>
		<div class="item"><i class="fa fa-user fa-fw"></i> 个人信息<i class="arrow"></i></div>
		<ul class="sub">
		<li><a href="usersCenter.php?mudi=revInfo">资料密码修改</a></li>
		'. AppLogin::UcMenu() .'
		'. AppSiteApi::UcMenu() .'
		'. (strpos($userSysArr['US_userMenuList'],'|noLog|') === false ? '<li><a href="usersCenter.php?mudi=log">会员日志</a></li>' : '') .'
		<li><a href="#" onclick="UserExit();return false;">退出</a></li>
		</ul>
	</li>
	</ul>
	</div>
	';


$tpl->Add('areaName',		$tpl->areaName);
$tpl->Add('webTop',			$webTop);
$tpl->Add('webMenu',		$webMenu);
$tpl->Add('webContent',		$webContent);

$tpl->Show('usersCenter.html');


function MainArea($content, $title, $faName='snowflake-o'){
	return '
		<div class="pointBox"><h4><i class="fa fa-'. $faName .'"></i>&ensp;&ensp;'. $title .'</h4></div>
		<div class="mainBox">'. $content .'</div>
		';
}
?>